var baseurl = "http://10.112.5.11/dashboard/ajax/router/rest.do";
function HttpUtils() {
	var ajaxRequest = function(method, ajaxmethod, params, callback) {
		var url = baseurl + "?ajaxmethod=" + ajaxmethod;
		$.ajax({
			type:method,
			url:url,
			data:params,
			datatype:"json",
			beforeSend:function(){
				
			},
			success:function(data, textStatus) {
				var code = data.code;
				if(!code) {
					alert("系统维护中，请稍后重试！");
					return;
				}
				if(code == "302") {
					window.location.href=data.data;
					return;
				}
				if(code != "1") {
					alert(data.message);
					return;
				}
				if(callback) {
					callback(data);
				}
			},
			error:function(XMLHttpRequest, textStatus, errorThrown){
				console.log(XMLHttpRequest.status); 
				console.log(XMLHttpRequest.readyState); 
				console.log(textStatus); 
				console.log(data);
				alert("系统维护中，请稍后重试！");
			}
		});
	}
	
	this.get = function(ajaxmethod, params, callback) {
		return ajaxRequest("GET", ajaxmethod, params, callback);
	}
	
	this.post = function(ajaxmethod, params, callback) {
		return ajaxRequest("POST", ajaxmethod, params, callback);
	}
}